Micron Document




Java syntax
part 21/46 · 86.7 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
assert n != 0;
/* If n equals 0, AssertionError will be thrown
with the message after the colon */
assert n != 0 : "n was equal to zero";

Primitive types

Primitive types in Java include integer types, floating-point numbers, UTF-16 code units and a Boolean type. There are no unsigned types in Java except char type, which is used to represent UTF-16 code units. The lack of unsigned types is offset by introducing unsigned right shift operation (>>>), which is not present in C++. Nevertheless, criticisms have been leveled about the lack of compatibility with C and C++ this causes.cite-ref-3[3]

| Primitive Types | Primitive Types | Primitive Types | Primitive Types | Primitive Types | Primitive Types |
|---|---|---|---|---|---|
| Type Name | Wrapper class | Value | Range | Size | Default Value |
| byte | java.lang.Byte | integer | −128 through +127 | 8-bit (1-byte) | 0 |
| short | java.lang.Short | integer | −32,768 through +32,767 | 16-bit (2-byte) | 0 |
| int | java.lang.Integer | integer | −2,147,483,648 through +2,147,483,647 | 32-bit (4-byte) | 0 |
| long | java.lang.Long | integer | −9,223,372,036,854,775,808 through +9,223,372,036,854,775,807 | 64-bit (8-byte) | 0 |
| float | java.lang.Float | floating point number | ±1.401298E−45 through ±3.402823E+38 | 32-bit (4-byte) | 0.0f [ 4 ] |
| double | java.lang.Double | floating point number | ±4.94065645841246E−324 through ±1.79769313486232E+308 | 64-bit (8-byte) | 0.0 |
| boolean | java.lang.Boolean | Boolean | true or false | 1-bit (1-bit) | false |
| char | java.lang.Character | UTF-16 code unit ( BMP character or a part of a surrogate pair) | '\u0000' through '\uFFFF' | 16-bit (2-byte) | '\u0000' |

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────